//+------------------------------------------------------------------+
//| new-trendline.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 initialization function |
//+------------------------------------------------------------------+
extern int MagicNumber=10001;
extern double Lots =0.01;
extern double TakeProfit=50;
extern int TrailingStop=50;
extern int Slippage=3;
extern int candle=20;
int OnInit()
{
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//---
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
//---
int CandlesOnChart=WindowFirstVisibleBar();
int HighestCandle = iHighest(_Symbol,_Period,MODE_HIGH,CandlesOnChart,2);
int lowestCandle = iLowest(_Symbol,_Period,MODE_LOW,CandlesOnChart,2);
int HighestCandle0 = iHighest(_Symbol,_Period,MODE_HIGH,10,2);
int LowestCandle0 = iLowest(_Symbol,_Period,MODE_LOW,10,2);
ObjectDelete("hightrend");
ObjectCreate(0,"hightrend",OBJ_TREND,0,Time[HighestCandle],
High[HighestCandle],Time[2],High[2]);
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[2],Low[2]);
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);
double bid = SymbolInfoDouble(_Symbol,SYMBOL_BID);
static double lastBid = bid;
string objName = "lowtrend";
string objName1 = "hightrend";
datetime time = TimeCurrent();
double price = ObjectGetValueByTime(0,objName,time);
double priceup = ObjectGetValueByTime(0,objName1,time);
//if(bid >= price && lastBid < price){
if(Close[1] > price && Close[0] > High[1] && Close[0] > High[2]){
Print("we hit line below ok Do buyy");
}
if(Low[1] > Close[0]){
Print("we hit line above ok exit buy");
}
if(Close[1] < priceup && Close[0] < Low[1] && Close[0] < Low[2]){
//if(bid <= price && lastBid > price){
Print("we hit line above ok Do selll");
}
if(High[1] < Close[0]){
Print("we hit line above ok exit sell");
}
lastBid = bid;
Comment("price",price , " priceup ",priceup,"\n bid ",bid, " lastbid ",lastBid);
}
//+------------------------------------------------------------------+
No comments:
Post a Comment