Arrow plot on high ?

To add comments, please log in or register
torexvir
261
torexvir  

Hey, i am trying to plot arrows on the highs and lows of the chart. I'm sure this has already been done but cannot find it online. An arrow has to be plotted at the high of the middle of three candles if the middle candle high is greater than the high to the left and to the right of it. The same goes for the lows, middle candle low is less than lows to the left and right of it. If this occurs plot an arrow at the high or low of that middle candle.

The code i have so far is attached but doesn't seem to be doing anything on the chart or during a backtest. Am i perhaps creating the object but not telling it to be plotted or is it my if statement is wrong as i don't even get the alert showing ?


Thanks in advance :)


int OnInit()

  {

//---

  int OPEN0 = Open[0];

  int CLOSE0 = Close[0];

  int OPEN1 = Open[1];

  int CLOSE1 = Close[1];

  int OPEN2 = Open[2];

  int CLOSE2 = Close[2];

  

  int HIGH0 =High[0]; //High of current candle

  int HIGH1 =High[1]; //High of previous canlde/middle candle

  int HIGH2 =High[2]; //High of third candle back

   

  if(HIGH0<HIGH1 && HIGH1>HIGH2)

  {

   Alert(High[1]);

   ObjectCreate(_Symbol, "DOWNARROW", OBJ_ARROW, 0,Time[1],High[1]);

   ObjectSetInteger(0,"DOWNARROW",OBJPROP_ARROWCODE,234);

   ObjectSetInteger(0, "DOWNARROW", OBJPROP_COLOR, clrGreen);

   ChartRedraw(0);

  }

  

  int LOW0 = Low[0]; //Low of current candle

  int LOW1 = Low[1]; //Low of previous candle/middle candle 

  int LOW2 = Low[2]; //Low of third candle back

  

  if(Low[0]>Low[1] && Low[1]<Low[2])

  {

  Alert (Low[1]);

  ObjectCreate(_Symbol, "UPARROW", OBJ_ARROW, 0, Time[1], Low[1]);

  ObjectSetInteger(0,"UPARROW",OBJPROP_ARROWCODE,233);

  ObjectSetInteger(0, "UPARROW", OBJPROP_COLOR, clrRed);

  ChartRedraw(0);

  }

//---

   return(INIT_SUCCEEDED);

  }

//+------------------------------------------------------------------+

//| Expert deinitialization function                                 |

//+------------------------------------------------------------------+

void OnDeinit(const int reason)

  {

//---

   

  }

//+------------------------------------------------------------------+

//| Expert tick function                                             |

//+------------------------------------------------------------------+

void OnTick()

  {

//---

 int OPEN0 = Open[0];

  int CLOSE0 = Close[0];

  int OPEN1 = Open[1];

  int CLOSE1 = Close[1];

  int OPEN2 = Open[2];

  int CLOSE2 = Close[2];

  

  int HIGH0 =High[0]; //High of current candle 

  int HIGH1 =High[1]; //High of Previous candle/middle candle 

  int HIGH2 =High[2]; //Low of third candle back

   

  if(HIGH0<HIGH1 && HIGH1>HIGH2)

  {

   Alert(High[1]);

   ObjectCreate(_Symbol, "DOWNARROW", OBJ_ARROW, 0,Time[1],High[1]);

   ObjectSetInteger(0,"DOWNARROW",OBJPROP_ARROWCODE,234);

   ObjectSetInteger(0, "DOWNARROW", OBJPROP_COLOR, clrGreen);

   ChartRedraw(0);

  }

  

  int LOW0 = Low[0]; //Low of current candle 

  int LOW1 = Low[1]; //Low of previous candle/middle candle 

  int LOW2 = Low[2]; //Low of third candle back 

  

  if(LOW0>LOW1 && LOW1<LOW2)

  {

  Alert (Low[1]);

  ObjectCreate(_Symbol, "UPARROW", OBJ_ARROW, 0, Time[1], Low[1]);

  ObjectSetInteger(0,"UPARROW",OBJPROP_ARROWCODE,233);

  ObjectSetInteger(0, "UPARROW", OBJPROP_COLOR, clrRed);

  ChartRedraw(0);

  

  }

  }

//+------------------------------------------------------------------+

.......


GrumpyDuckMan
882
GrumpyDuckMan  
Hello,
Try using Fractal.
torexvir
261
torexvir  
GrumpyDuckMan:
Hello,
Try using Fractal.

Perfect, exactly what i was looking for and it was in front of me the whole time. I need to make a few tweaks but its what i needed 

Thank you

GrumpyDuckMan
882
GrumpyDuckMan  
torexvir:

Perfect, exactly what i was looking for and it was in front of me the whole time. I need to make a few tweaks but its what i needed 

Thank you

Hello friend,

what are you going to tweak?

if you haven't used it before. Isn't learning to walk easier than running

 Its only an indication.

torexvir
261
torexvir  
GrumpyDuckMan:

Hello friend,

what are you going to tweak?

if you haven't used it before. Isn't learning to walk easier than running

 Its only an indication.

Hi, 

I just changed it so i didn't need two candles either side of the Fractal just one candle. 

It adds a little bit more noise i suppose but its what i use with my script on Tradingview.

:)

To add comments, please log in or register