MnQInvestmentDevelopment/MnQInvestment/01_Amadeus/AMA-DEUSDEUSDEUS.mq5
super.admin cff55d2704 convert
2025-05-30 15:08:44 +02:00

80 lines
2.5 KiB
MQL5

#property copyright "Copyright 2023, M & Q Investment Group"
#property link "https://www.mql5.com"
#property version "1.00"
#include <trade/trade.mqh>
CTrade trade;
//-------------------------------------------BASIC TEST IF CONCEPT WORKS -------------
input double TrigPDif = 0.00005;
input double SLDif = 0.001;
input double TPDif = 0.001;
input double LotS = 1.0;
input int ExpiryTime = 120;
//bool OrderinAction;
double bid1 = 0;
double bid0 = 0;
double accountbalancebeginning;
double accountprofit;
int OnInit(){
accountbalancebeginning = AccountInfoDouble(ACCOUNT_BALANCE);
//OrderinAction = false;
return(INIT_SUCCEEDED);
}
void OnTick(){
//GET RED AMA VALUES
double AMAPriceArray[];
int AMADefinition = iAMA (_Symbol,_Period,5,2,30,0,PRICE_CLOSE);
ArraySetAsSeries(AMAPriceArray,true);
//AMA DEF, one line, current candle, 3 candles, store result
CopyBuffer(AMADefinition,0,0,3,AMAPriceArray);
double AMACurrentValue = NormalizeDouble(AMAPriceArray[0],6);
Comment("AMA-Value ",AMACurrentValue);
//GET PRICE VALUES
MqlRates CurrentPriceArray[];
int copied = CopyRates(_Symbol,PERIOD_CURRENT,0,3,CurrentPriceArray);
ArraySetAsSeries(CurrentPriceArray, true);
//SET THE ORDER
bid1 = bid0;
bid0 = NormalizeDouble(SymbolInfoDouble(_Symbol,SYMBOL_BID),_Digits);
if(bid0 <= AMAPriceArray[0] && bid1 > AMAPriceArray[1] && PositionsTotal() == 0 && OrdersTotal() == 0/*&& OrderinAction == false*/){
double TrigP = bid0 - TrigPDif;
double TP = TrigP - TPDif;
double SL = TrigP + SLDif;
datetime OrderExpTime = TimeCurrent() + ExpiryTime;
trade.SellStop(LotS,TrigP,_Symbol,SL,TP,ORDER_TIME_SPECIFIED,OrderExpTime);
//OrderinAction = true;
}
/*/DELETE ORDER
if(bid0 >= AMAPriceArray[0] - TrigPDif && OrderinAction == true){
ulong Positionticket = PositionGetTicket(0);
trade.OrderDelete(Positionticket);
}*/
// DISPLAY OF VALUES ON CHART
double accountbalance = AccountInfoDouble(ACCOUNT_BALANCE);
double accountequity = AccountInfoDouble(ACCOUNT_EQUITY);
accountprofit = accountequity - accountbalancebeginning;
accountprofit = NormalizeDouble(accountprofit,2);
Comment("\nServertime: ", TimeCurrent(),
"\nCurrenttime: ",TimeCurrent(),
"\nProfit: ",accountprofit,
"\nEquity: ",accountequity);
}