Support Board
Date/Time: Sun, 24 Nov 2024 20:32:06 +0000
[User Discussion] - StepMA
View Count: 7881
[2014-07-13 13:15:27] |
crazybears - Posts: 314 |
Hi I'm trying to code step ma code from NT to SC https://www.bigmiketrading.com/local_links.php?catid=4&linkid=93 I can't reproduce it I don't understand where I'm wrong with code Has someone already code it and willing to share Thanks |
[2014-07-15 00:32:14] |
vegasfoster - Posts: 444 |
Can you post the NT code here?
|
[2014-07-15 08:25:49] |
crazybears - Posts: 314 |
Hi Vegas these are the codes for NT , AB e MT which i tried to copy. they can be open by Notepad++ thanks |
StepMA_v7.2.cs - Attached On 2014-07-15 08:19:33 UTC - Size: 13.99 KB - 799 views stepMA.afl - Attached On 2014-07-15 08:19:58 UTC - Size: 1.66 KB - 819 views StepMA_v7.mq4 - Attached On 2014-07-15 08:20:29 UTC - Size: 5.54 KB - 605 views |
[2014-07-17 01:11:27] |
vegasfoster - Posts: 444 |
Ok, will work on this tomorrow. It looks easy, but it often does ;-)
|
[2014-07-17 22:52:29] |
swandro - Posts: 11 |
crazybears, I am confused. You also posted a cpp version on BMT, which I compiled and it seemed to work. vegasfoster might want to take a look at it. Don't mean to interfere. |
[2014-07-17 22:52:47] |
vegasfoster - Posts: 444 |
Hi, so the calculation changes depending on whether you are using the sma or lwma as the moving average type. I don't see code for the lwma in SC, can you post the ninjascript file for that as well? Unless someone can point me to it. Other option, if you don't use the lwma then I can just do it for sma.
Date Time Of Last Edit: 2014-07-17 22:53:33
|
[2014-07-17 23:55:20] |
vegasfoster - Posts: 444 |
Couple more questions, 1. What are the values you are using for Percentage, UpDownShift, HighLow, and ColorMode parameters? No defaults are specified for these and I don't know what to start with. 2. Is there a description provided for the different color modes, or is it just 0, 1, 2, 3? |
[2014-07-18 00:04:21] |
crazybears - Posts: 314 |
Hi swandro what i posted on BM was my draft but doesn't work as NT code. https://www.bigmiketrading.com/local_links.php?catid=4&linkid=93 i missed this option , here is the code i found on BM forum thanks |
LWMA.txt - Attached On 2014-07-18 00:00:50 UTC - Size: 2.52 KB - 700 views |
[2014-07-18 00:09:50] |
crazybears - Posts: 314 |
public class StepMA : Indicator
{ //Inputs private int _length = 10; // Volty Length private double _kv = 0.5; // Sensivity Factor private int _stepSize = 20; // Constant Step Size (if need) private int _maType; // Volty MA Mode : 0-SMA, 1-LWMA private double _percentage; // Percentage of Up/Down Moving private double _upDownShift; // Number of Up/Down Moving, in points. For ColorMode==3 only. private bool _highLow; // High/Low Mode Switch (more sensitive) private int _colorMode = 2; // Color Mode Switch private double stepMA, ATR0, ATRmax = -100000, ATRmin = 1000000; private int limit; |
[2014-07-19 17:36:49] |
vegasfoster - Posts: 444 |
Draft 1 Complete! Unfortunately, may have gotten a few errors I have to work through :(. Probably take a couple days unless someone else does it first.
|
[2014-07-26 06:10:39] |
User84094 - Posts: 47 |
Draft 2 ?
|
[2014-07-26 16:38:52] |
vegasfoster - Posts: 444 |
I did this, but the plot wasn't coming out, see pic. I went through it a couple times and my translation error didn't jump out at me. The only way I know how to resolve this is to break it down by section and compare the plots for the calculations on SC vs NT. However, I don't have NT installed and I have yet to find the motivation to follow through on this. So I am going to post what I have, see attachment. Unless someone else already finished this for you, maybe you can take a look and compare the codes and try to see where it is going wrong, if not then next step is to start going through the individual calculations and comparing to NT. Understand, it may not be exact because of how each program calculates the bar data, but looking at the plot you will be able to see if it working correctly or not. #include "sierrachart.h" SCDLLName("StepMA2") /*==========================================================================*/ SCFloatArrayRef StepSizeCalc(SCStudyGraphRef sc, SCFloatArrayRef result, int Index, int Len, double Km, int Size, int k, int MaType) { if (Index <= Len+1) return result; else { double ATR0, ATRmax = -100000, ATRmin = 1000000; if (Size == 0) { double AvgRange = 0; double Weight = 0; for (int i = Len-1; i >= 0; i--) { double alfa = (MaType == 0) ? 1.0 : 1.0*(Len-i)/Len; AvgRange += alfa*(sc.High[k+i]-sc.Low[k+i]); Weight += alfa; } ATR0 = AvgRange/Weight; if (ATR0 > ATRmax) ATRmax = ATR0; if (ATR0 < ATRmin) ATRmin = ATR0; result[Index] = round(0.5*Km*(ATRmax+ATRmin)/sc.TickSize); } else result[Index] = Km*Size; return result; } } /*==========================================================================*/ SCFloatArrayRef StepMACalc(SCStudyGraphRef sc, SCFloatArrayRef result, int Index, int Len, bool HL, double Size) { SCFloatArrayRef smax = sc.Subgraph[Index]; SCFloatArrayRef smin = sc.Subgraph[Index].Arrays[0]; SCFloatArrayRef trend = sc.Subgraph[Index].Arrays[1]; if (HL) { smax[Index] = sc.Low[Index]+2.0*Size*sc.TickSize; smin[Index] = sc.High[Index]-2.0*Size*sc.TickSize; } else { smax[Index] = sc.Close[Index]+2.0*Size*sc.TickSize; smin[Index] = sc.Close[Index]-2.0*Size*sc.TickSize; } if (Index == Len) { smax[Index-1] = smax[Index]; smin[Index-1] = smin[Index]; trend[Index-1] = 0; } trend[Index] = trend[Index-1]; if (sc.Close[Index] > smax[Index-1]) trend[Index] = 1; if (sc.Close[Index] < smin[Index-1]) trend[Index] = -1; if (trend[Index] > 0) { if (smin[Index] < smin[Index-1]) smin[Index] = smin[Index-1]; result[Index] = smin[Index]+Size*sc.TickSize; } else { if (smax[Index] > smax[Index-1]) smax[Index] = smax[Index-1]; result[Index] = smax[Index]-Size*sc.TickSize; } return result; } /*==========================================================================*/ SCFloatArrayRef TrendCalc(SCStudyGraphRef sc, SCFloatArrayRef trend, int Index, int Len, bool HL, double Size) { SCFloatArrayRef smax = sc.Subgraph[Index]; SCFloatArrayRef smin = sc.Subgraph[Index].Arrays[0]; if (HL) { smax[Index] = sc.Low[Index]+2.0*Size*sc.TickSize; smin[Index] = sc.High[Index]-2.0*Size*sc.TickSize; } else { smax[Index] = sc.Close[Index]+2.0*Size*sc.TickSize; smin[Index] = sc.Close[Index]-2.0*Size*sc.TickSize; } if (Index == Len) { smax[Index-1] = smax[Index]; smin[Index-1] = smin[Index]; trend[Index-1] = 0; } trend[Index] = trend[Index-1]; if (sc.Close[Index] > smax[Index-1]) trend[Index] = 1; if (sc.Close[Index] < smin[Index-1]) trend[Index] = -1; //if (trend[Index] > 0) //{ // if (smin[Index] < smin[Index-1]) smin[Index] = smin[Index-1]; // result[Index] = smin[Index]+Size*sc.TickSize; //} //else //{ // if (smax[Index] > smax[Index-1]) smax[Index] = smax[Index-1]; // result[Index] = smax[Index]-Size*sc.TickSize; //} return trend; } /*==========================================================================*/ SCSFExport scsf_StepMA2(SCStudyInterfaceRef sc) { SCSubgraphRef LineBuffer = sc.Subgraph[0]; SCSubgraphRef UpBuffer = sc.Subgraph[1]; SCSubgraphRef DnBuffer = sc.Subgraph[2]; SCSubgraphRef stepsizeout = sc.Subgraph[10]; SCSubgraphRef stepmaout = sc.Subgraph[11]; SCSubgraphRef trendout = sc.Subgraph[11]; SCInputRef length = sc.Input[0]; SCInputRef kv = sc.Input[1]; SCInputRef stepsize = sc.Input[2]; SCInputRef percentage = sc.Input[3]; SCInputRef updownshift = sc.Input[4]; SCInputRef matype = sc.Input[5]; SCInputRef highlow = sc.Input[6]; SCInputRef colormode = sc.Input[7]; if (sc.SetDefaults) { sc.GraphName = "StepMA2"; sc.AutoLoop = true; sc.FreeDLL = 1; LineBuffer.Name = "Neutral"; LineBuffer.LineWidth = 1; UpBuffer.Name = "Up"; UpBuffer.LineWidth = 1; DnBuffer.Name = "Down"; DnBuffer.LineWidth = 1; length.Name = "Length"; length.SetInt(10); kv.Name = "Sensitivity Factor"; kv.SetDouble(0.5); stepsize.Name = "Step Size"; stepsize.SetInt(20); percentage.Name = "Percentage"; percentage.SetDouble(0.5); updownshift.Name = "Shift in Points"; updownshift.SetDouble(2); matype.Name = "MA Type"; matype.SetCustomInputStrings("SMA;LWMA"); matype.SetCustomInputIndex(0); highlow.Name = "HighLow Mode"; highlow.SetCustomInputStrings("0;1"); highlow.SetCustomInputIndex(0); colormode.Name = "ColorMode"; colormode.SetCustomInputStrings("0;1;2;3"); colormode.SetCustomInputIndex(0); return; } // Do data processing double stepMA; if (sc.Index > length.GetInt()) { StepSizeCalc(sc, stepsizeout, length.GetInt(), sc.Index, kv.GetDouble(), stepsize.GetInt(), 0, matype.GetIndex()); double stepsizeoutb = stepsizeout[sc.Index]; StepMACalc(sc, stepmaout, sc.Index, length.GetInt(), highlow.GetIndex(), stepsizeoutb); TrendCalc(sc, trendout, sc.Index, length.GetInt(), highlow.GetIndex(), stepsizeoutb); stepMA = stepmaout[sc.Index]+percentage.GetDouble()/100.0*stepsizeout[sc.Index]*sc.TickSize; if (colormode.GetIndex() == 0) LineBuffer[sc.Index] = stepMA; if (colormode.GetIndex() == 1) { if (trendout[sc.Index] > 0) { UpBuffer[sc.Index] = stepMA-stepsizeout[sc.Index]*sc.TickSize; } else if (trendout[sc.Index] < 0) { DnBuffer[sc.Index] = stepMA+stepsizeout[sc.Index]*sc.TickSize; } } else if (colormode.GetIndex() == 2) { if (trendout[sc.Index] > 0) { UpBuffer[sc.Index] = stepMA+updownshift.GetDouble()*sc.TickSize; if (trendout[sc.Index-1] < 0) UpBuffer[sc.Index-1] = DnBuffer[sc.Index-1]; } if (trendout[sc.Index] < 0) { DnBuffer[sc.Index] = stepMA-updownshift.GetDouble()*sc.TickSize; if (trendout[sc.Index-1] > 0) DnBuffer[sc.Index-1] = UpBuffer[sc.Index-1]; } } //end if ( colormode == 2) else if (colormode.GetIndex() == 3) { if (trendout[sc.Index] > 0) { UpBuffer[sc.Index] = stepMA+(stepsizeout[sc.Index]+updownshift.GetDouble())*sc.TickSize; } else if (trendout[sc.Index] < 0) { DnBuffer[sc.Index] = stepMA-(stepsizeout[sc.Index]+updownshift.GetDouble())*sc.TickSize; } } //end if ( colormode == 3) else { LineBuffer[sc.Index] = stepMA; } } } |
StepMA-2.cpp - Attached On 2014-07-26 16:33:44 UTC - Size: 8 KB - 652 views StepMA.png / V - Attached On 2014-07-26 16:37:43 UTC - Size: 57.85 KB - 602 views |
[2014-07-27 21:58:12] |
crazybears - Posts: 314 |
thanks vegas i try to work on your code
|
[2014-07-27 22:16:42] |
crazybears - Posts: 314 |
change SCSubgraphRef stepmaout = sc.Subgraph[11]; SCSubgraphRef trendout = sc.Subgraph[11]; to SCSubgraphRef stepmaout = sc.Subgraph[11]; SCSubgraphRef trendout = sc.Subgraph[12]; |
[2014-07-28 04:53:25] |
vegasfoster - Posts: 444 |
Pfft, see wasn't even looking at that, glad you figured it :-)
|
[2014-08-09 22:29:25] |
crazybears - Posts: 314 |
New Draft :) ok i tried several ways to replicate Step MA indicator as NT without success. thinking something similar i tried to modify adaptive moving percentile indicator and zigzag indicator , using zigzag length and distance between it and adaptive moving percentile as signal to point out if a trend is started or not. i set min mov zz to 0.21 means zz lines have moved 21 ticks (CL) distance between price and percentile 0.2 zzline to 0.08 1 bar maybe one would find it useful , attached is the code , it's a draft ,hope someone can improve it http://www.sierrachart.com/image.php?l=1407622521519.png purpose it's to replicate Alpha Trading Method from NT to SC. https://www.bigmiketrading.com/elite-trading-journals/30600-alpha-trading-method-ninjatrader-advanced-trade-management-jdneeman.html https://www.bigmiketrading.com/elite-trading-journals/32193-ninjatrader-advanced-trade-management-trading-method-vendor-free.html https://www.bigmiketrading.com/elite-automated-trading/32559-ron-s-alpha-trade-method-ninjatrader-advanced-trade-management-bot.html other indicators are already in SC |
ZZLINE.cpp - Attached On 2014-08-09 22:16:45 UTC - Size: 9.11 KB - 719 views AdaptiveMovingPercentile2.cpp - Attached On 2014-08-09 22:16:54 UTC - Size: 9.69 KB - 783 views |
[2018-05-05 16:06:25] |
User964132 - Posts: 93 |
Hi I think it is the same indicator I try to get for sierra charts: I posted the updated mq4 and a simplified Easylanguage code in the following post: Converting MT4 indicator StepUp for Sierra charts Regards, Nicolaas |
[2024-04-27 22:44:50] |
User411320 - Posts: 289 |
I downloaded and put the STEPma in the data folder but don't see it. please help
|
To post a message in this thread, you need to log in with your Sierra Chart account: