Metatrader Forum | Forex Expert-Advisor | Broker & Forex Tools

Metatrader Forum | Forex Expert-Advisor | Broker & Forex Tools (http://www.expert-advisor.com/forum/index.php)
-   Programmierung MQL4 (http://www.expert-advisor.com/forum/forumdisplay.php?f=220)
-   -   Frage zu meinem Script (TrailingStop) (http://www.expert-advisor.com/forum/showthread.php?t=6301)

Stinky 09.01.19 12:13

Frage zu meinem Script (TrailingStop)
 
Hallo zusammen, ich bin ganz neu im MetaEditor und hoffe das mir jemand hier aushelfen kann.

Ich probiere schon länger in meinem kleinen Script einen Trailing Stop einzufügen. Finde im Internet leider nichts evtl. kann mir hier jemand helfen.

Was ich Anfänger bis jetzt habe:

PHP-Code:


// Version 0.01
#property copyright "Copyright 2019, Laurent Häuslein"

input int TPPoints 100;
input int SLPoints 50;

input int RSIPeriods 14;
input int Top 70;
input int Bottom 30;
input int Magic 1;




int orderTicket

int OnInit()
  {

   return(
INIT_SUCCEEDED);
  }

void OnDeinit(const int reason)
  {

   
  }

void OnTick(){
   
double rsi;
   
rsi iRSI(Symbol(), PERIOD_CURRENT,RSIPeriods,PRICE_CLOSE,0);

      if(
rsi Top) {
      
         if(
OrderSelect(orderTicket,SELECT_BY_TICKET) == true) {
            if(
OrderType() == OP_BUY) {
               
bool res OrderClose(OrderTicket(),OrderLots(),Bid,1000,clrNONE);
                  
orderTicket 0;
                  }            
               }
      if(
orderTicket <= 0) {
         
orderTicket executShort();
     }
     }
     else if(
rsi Bottom) {
         if(
OrderSelect(orderTicket,SELECT_BY_TICKET) == true) {
            if(
OrderType() == OP_SELL) {
               
bool res OrderClose(OrderTicket(),OrderLots(),Ask,1000,clrNONE);
                  
orderTicket 0;
                  }
               }
            if(
orderTicket <= 0) {
                
orderTicket executLong();
     }
     }
     }
     
     
     
int executShort () {
   
double entry Bid
   
double tp entry TPPoints Point;
   
double sl entry SLPoints Point;
   
   
int ticket;
   
ticket OrderSend(Symbol(), OP_SELL,Lots,entry,1000,sl,tp,"OP_SELL",Magic,0,clrNONE);
   return 
ticket;
  }

int executLong () {
   
double entry Bid;
   
double tp entry TPPoints Point;
   
double sl entry SLPoints Point;
  
   
int ticket;
   
ticket OrderSend(Symbol(), OP_BUY,Lots,entry,1000,sl,tp,"OP_SELL",Magic,0,clrNONE);
   return 
ticket;
  } 


Adlerauge 09.01.19 17:41

Moin,

im offiziellen MQL4-book findest Du einen Trailing-Stop:

https://book.mql4.com/trading/ordermodify


Alle Zeitangaben in WEZ +2. Es ist jetzt 18:43 Uhr.

Powered by vBulletin® Version 3.8.5 (Deutsch)
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.6.1
Powered by vBCMS® 2.7.0 ©2002 - 2024 vbdesigns.de
Copyright ©2009 - 2023 by Expert-Advisor.com - Das Metatrader Forum