Skip to content

Instantly share code, notes, and snippets.

@waqaskhan137
Last active October 9, 2022 04:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save waqaskhan137/28ca22e24e2e7df96ebf71d65cfaad3c to your computer and use it in GitHub Desktop.
Save waqaskhan137/28ca22e24e2e7df96ebf71d65cfaad3c to your computer and use it in GitHub Desktop.
//+------------------------------------------------------------------+
//| test.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 |
//+------------------------------------------------------------------+
double pSt=0;
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int OnInit()
{
//---
//---
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//---
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
//---
string signal = "";
double st = iStochastic(_Symbol,_Period,3,3,14,MODE_EMA,20/80,MODE_MAIN,0);
printf(StringConcatenate("Current st : ", st, " Previous St : ", pSt));
// double pSt = iStochastic(_Symbol,_Period,3,3,14,MODE_EMA,20/80,MODE_MAIN,0);
if(pSt < 80 && st > 80 && Bid > High[1])
{
signal = "BUY";
printf("Buy Signal Generated");
int a = OrderSend(_Symbol,OP_BUY,0.40,Ask,2,7,Ask+8,"RMA",0,0,0);
}
else
if(pSt > 80 && st < 80 && Ask < Low[1])
{
signal = "SELL";
printf("Sell Signal Generated");
int a = OrderSend(_Symbol,OP_SELL,0.40,Ask,2,7,Ask+8,"RMA",0,0,0);
}
pSt = st;
}
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment