Wednesday, July 20, 2022

Trend Line Indicator for mt4

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

//|                                                        trend.mq4 |

//|                        Copyright 2022, MetaQuotes Software Corp. |

//|                                             https://www.mql5.com |

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

#property copyright "Copyright 2022, MetaQuotes Software Corp."

#property link      "https://www.mql5.com"

#property version   "1.00"

#property strict

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

//| Expert tick function                                             |

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

void OnTick()

  {

int CandlesOnChart=WindowFirstVisibleBar();

int HighestCandle = iHighest(_Symbol,_Period,MODE_HIGH,CandlesOnChart,0);

int lowestCandle = iLowest(_Symbol,_Period,MODE_LOW,CandlesOnChart,0);


ObjectDelete("hightrend");

ObjectCreate(0,"hightrend",OBJ_TREND,0,Time[HighestCandle],

High[HighestCandle],Time[0],High[0]);

   

  ObjectSetInteger(0,"hightrend",OBJPROP_COLOR,Red);

  ObjectSetInteger(0,"hightrend",OBJPROP_STYLE,STYLE_SOLID);

  ObjectSetInteger(0,"hightrend",OBJPROP_WIDTH,1);

  ObjectSetInteger(0,"hightrend",OBJPROP_RAY,true);

  

  ObjectDelete("lowtrend");

ObjectCreate(0,"lowtrend",OBJ_TREND,0,Time[lowestCandle],

Low[lowestCandle],Time[0],Low[0]);

   

  ObjectSetInteger(0,"lowtrend",OBJPROP_COLOR,Yellow);

  ObjectSetInteger(0,"lowtrend",OBJPROP_STYLE,STYLE_SOLID);

  ObjectSetInteger(0,"lowtrend",OBJPROP_WIDTH,1);

  ObjectSetInteger(0,"lowtrend",OBJPROP_RAY,true);

 

  };

  

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


No comments:

Post a Comment