Hi folks,
Im looking for some help!
Here is a afl code, which plots nicely stop and profit levels based on the day you clicked.
This makes it easy to study trades visually.
_SECTION_BEGIN("__pricechart with automatic lines");
SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
PlotOHLC( O, H, L, C, "" , colorWhite, styleCandle);
// ******** CHARTING
STOPLOSS = 2.0;
PROFIT = 3.5;
EPT1= 1.5;
EPT2= 2.0;
EPT3= 2.5;
EPT4= 3.0;
mystartbar = SelectedValue(BarIndex()); // FOR GRAPHING
mystartbardate = LastValue(ValueWhen(mystartbar == BarIndex(),DateNum(),1));
InitialValue = LastValue(ValueWhen(mystartbardate == DateNum(), O , 1 ) ) ;
Temp1 = IIf(BarIndex() >= mystartbar, InitialValue, Null) ;
Verline = DateNum() == ParamDate("Date", "01/11/2011", 0);
LinesLONG = ParamToggle("Show lines LONG ","No|Yes",0);
LinesSHORT = ParamToggle("Show lines SHORT ","No|Yes",0);
if (LinesLONG ) Plot(Temp1, "OPEN ", colorYellow,styleLine) AND
Plot((1-(LastValue(STOPLOSS)/100))*(Temp1), "STOPLOSS ", colorRed, styleLine) AND
Plot((1+(LastValue(PROFIT)/100))*(Temp1), "PROFIT ", colorGreen, styleLine) AND
Plot((1+(LastValue(EPT1)/100))*(Temp1), "EPT1 ", colorWhite, styleLine|styleDashed) AND
Plot((1+(LastValue(EPT2)/100))*(Temp1), "EPT2 ", colorWhite, styleLine|styleDashed) AND
Plot((1+(LastValue(EPT3)/100))*(Temp1), "EPT3 ", colorWhite, styleLine|styleDashed) AND
Plot((1+(LastValue(EPT4)/100))*(Temp1), "EPT4 ", colorWhite, styleLine|styleDashed) AND
Plot(Verline , "", colorRed, styleHistogram | styleOwnScale | styleThick | styleNoLabel); //vertical line on entered day
if (LinesSHORT ) Plot(Temp1, "OPEN ", colorYellow,styleLine) AND
Plot((1+(LastValue(STOPLOSS)/100))*(Temp1), "STOPLOSS ", colorRed, styleLine) AND
Plot((1-(LastValue(PROFIT)/100))*(Temp1), "PROFIT ", colorGreen, styleLine) AND
Plot((1-(LastValue(EPT1)/100))*(Temp1), "EPT1 ", colorWhite, styleLine|styleDashed) AND
Plot((1-(LastValue(EPT2)/100))*(Temp1), "EPT2 ", colorWhite, styleLine|styleDashed) AND
Plot((1-(LastValue(EPT3)/100))*(Temp1), "EPT3 ", colorWhite, styleLine|styleDashed) AND
Plot((1-(LastValue(EPT4)/100))*(Temp1), "EPT4 ", colorWhite, styleLine|styleDashed) AND
Plot(Verline , "", colorRed, styleHistogram | styleOwnScale | styleThick | styleNoLabel); //vertical line on entered day
_SECTION_END();
However, I would prefer a more static way. Enter a date in the parameters, and select Show lines LONG or Show lines SHORT, and it should plot the lines from the entered day
to the right.
I tried different ways, but don't get the results I want. Does anyone see a solution?
Im looking for some help!
Here is a afl code, which plots nicely stop and profit levels based on the day you clicked.
This makes it easy to study trades visually.
_SECTION_BEGIN("__pricechart with automatic lines");
SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
PlotOHLC( O, H, L, C, "" , colorWhite, styleCandle);
// ******** CHARTING
STOPLOSS = 2.0;
PROFIT = 3.5;
EPT1= 1.5;
EPT2= 2.0;
EPT3= 2.5;
EPT4= 3.0;
mystartbar = SelectedValue(BarIndex()); // FOR GRAPHING
mystartbardate = LastValue(ValueWhen(mystartbar == BarIndex(),DateNum(),1));
InitialValue = LastValue(ValueWhen(mystartbardate == DateNum(), O , 1 ) ) ;
Temp1 = IIf(BarIndex() >= mystartbar, InitialValue, Null) ;
Verline = DateNum() == ParamDate("Date", "01/11/2011", 0);
LinesLONG = ParamToggle("Show lines LONG ","No|Yes",0);
LinesSHORT = ParamToggle("Show lines SHORT ","No|Yes",0);
if (LinesLONG ) Plot(Temp1, "OPEN ", colorYellow,styleLine) AND
Plot((1-(LastValue(STOPLOSS)/100))*(Temp1), "STOPLOSS ", colorRed, styleLine) AND
Plot((1+(LastValue(PROFIT)/100))*(Temp1), "PROFIT ", colorGreen, styleLine) AND
Plot((1+(LastValue(EPT1)/100))*(Temp1), "EPT1 ", colorWhite, styleLine|styleDashed) AND
Plot((1+(LastValue(EPT2)/100))*(Temp1), "EPT2 ", colorWhite, styleLine|styleDashed) AND
Plot((1+(LastValue(EPT3)/100))*(Temp1), "EPT3 ", colorWhite, styleLine|styleDashed) AND
Plot((1+(LastValue(EPT4)/100))*(Temp1), "EPT4 ", colorWhite, styleLine|styleDashed) AND
Plot(Verline , "", colorRed, styleHistogram | styleOwnScale | styleThick | styleNoLabel); //vertical line on entered day
if (LinesSHORT ) Plot(Temp1, "OPEN ", colorYellow,styleLine) AND
Plot((1+(LastValue(STOPLOSS)/100))*(Temp1), "STOPLOSS ", colorRed, styleLine) AND
Plot((1-(LastValue(PROFIT)/100))*(Temp1), "PROFIT ", colorGreen, styleLine) AND
Plot((1-(LastValue(EPT1)/100))*(Temp1), "EPT1 ", colorWhite, styleLine|styleDashed) AND
Plot((1-(LastValue(EPT2)/100))*(Temp1), "EPT2 ", colorWhite, styleLine|styleDashed) AND
Plot((1-(LastValue(EPT3)/100))*(Temp1), "EPT3 ", colorWhite, styleLine|styleDashed) AND
Plot((1-(LastValue(EPT4)/100))*(Temp1), "EPT4 ", colorWhite, styleLine|styleDashed) AND
Plot(Verline , "", colorRed, styleHistogram | styleOwnScale | styleThick | styleNoLabel); //vertical line on entered day
_SECTION_END();
However, I would prefer a more static way. Enter a date in the parameters, and select Show lines LONG or Show lines SHORT, and it should plot the lines from the entered day
to the right.
I tried different ways, but don't get the results I want. Does anyone see a solution?