- December 29, 2013
- Posted by: Forex Wiki Team
- Category: Expert Advisor
Name: |
|
||
Author: | tonny (2011.11.11 10:22) | ||
Downloaded: | 6091 | ||
Download: |
|
||
Description:An Expert Advisor designed to open and close respective orders at the first parabolic SAR signal. Its performance depends on the custom parameters of stop loss, take profit, trailing stop, lot size for opening trades and more. This version works alongside manual trades and other expert advisors as per you requests. Note:1.) You need to change the SAR indicator "Step" and "maximum" value/s to that of the EA in order to match the EA operation with that of the SAR indicator. But this is just for visual purposes as the EA does'nt need the indicator in order to work. e.g. if you are using the default step setting for the EA (0.001) you might get a false impression that the EA didnt open an order when the SAR indicator with its default step setting (0.02) showed a signal but in reality the virtual SAR with a step setting of 0.001 had'nt yet shown a signal. If no order was opened and the journal displayed an error as to why, thats when action needs to be taken. Always check this page for updates thank you !!!. Ive also included a full documentation for pSAR bug 7 available at our new site.
2.) Please do your own strategy testing to find the best strategy; the default settings do not necessarily represent the best strategy but is just a place holder.
|
|||
FXSysssr:
Hi Tonny, Yes, under 'Common Tab' I have 'Live Trading' checked and 'Manual Confirmation' unchecked. I tested it on the 1M and 5M GBP/USD charts, no orders are opening automatically, no error messages in Journal. Works perfectly with Manual Confirmation though. Any other suggestions, please let me know... Thanks tonny:
FXSysssr:
Hello Tonny, Unable to get Psar Bug 7 to work without Manual Confirmation. My Sar settings match in EA and indicator (Step .03, Max .2) On platform, Tools ---> Options ---> Unchecked 'Manual Confirmation' What am I doing wrong? Thank you. When you attach the ea and the settings dialogue appears there is a tab called "common" this tab also has settings for live trading and manual confirmation please check if "allow live trading" is checked and "ask manual confirmation" should be unchecked. Confirmation of trade operations is built in mt4 not EAs. Try uninstalling and reinstalling your meta trader. 15.11.2011 11:30 tonny
Hi Tonny, Yes, under 'Common Tab' I have 'Live Trading' checked and 'Manual Confirmation' unchecked. I tested it on the 1M and 5M GBP/USD charts, no orders are opening automatically, no error messages in Journal. Works perfectly with Manual Confirmation though. Any other suggestions, please let me know... Thanks tonny:
FXSysssr:
Hello Tonny, Unable to get Psar Bug 7 to work without Manual Confirmation. My Sar settings match in EA and indicator (Step .03, Max .2) On platform, Tools ---> Options ---> Unchecked 'Manual Confirmation' What am I doing wrong? Thank you. When you attach the ea and the settings dialogue appears there is a tab called "common" this tab also has settings for live trading and manual confirmation please check if "allow live trading" is checked and "ask manual confirmation" should be unchecked. 15.11.2011 10:51 FXSysssr
deVries:
tonny:
devries you also might wana read the full psar bug documentation http://www.mql4.com/go?http://www.fxautomated.com/docs/psarbugdoc.php to understand this EA better. The magic number is editable by the user making it more flexible thus its enough to only select magic number only and not ordersymbol too since on different charts, timeframes etc the user can set a different magic number afterall thats the work of magic number otherwise i would'nt have made it editable on the user side. if((Trailing==true)&&(OrdersTotal()>0)){ //----------------------------------------------------------------------------------------------------------------------- // Trail /*-----------------------------------------------------------------------------------------------------------------------*/ string Symb=Symbol(); // Symbol //------------------------------------------------------------------------------- 2 -- for(i=1; i<=OrdersTotal(); i++) // Cycle searching in orders { if (OrderSelect(i-1,SELECT_BY_POS)==true) // If the next is available { // Analysis of orders: int Tip=OrderType(); // Order type if(OrderSymbol()!=Symb||Tip>1)continue;// The order is not "ours" double SLt=OrderStopLoss(); // SL of the selected order //---------------------------------------------------------------------- 3 -- while(true) // Modification cycle { double TS=Tral_Stop; // Initial value int Min_Dist=MarketInfo(Symb,MODE_STOPLEVEL);//Min. distance if (TS < Min_Dist) // If less than allowed TS=Min_Dist; // New value of TS //------------------------------------------------------------------- 4 -- bool Modify=false; // Not to be modified switch(Tip) // By order type { case 0 : // Order Buy if (NormalizeDouble(SLt,Digits)< // If it is lower than we want NormalizeDouble(Bid-TS*Point,Digits)) { SLt=Bid-TS*Point; // then modify it string Text="Buy "; // Text for Buy Modify=true; // To be modified } break; // Exit 'switch' case 1 : // Order Sell if (NormalizeDouble(SLt,Digits)> // If it is higher than we want NormalizeDouble(Ask+TS*Point,Digits) || NormalizeDouble(SLt,Digits)==0)//or equal to zero { SLt=Ask+TS*Point; // then modify it Text="Sell "; // Text for Sell Modify=true; // To be modified } } // End of 'switch' if (Modify==false) // If it is not modified break; // Exit 'while' //------------------------------------------------------------------- 5 -- double TPt =OrderTakeProfit(); // TP of the selected order double Price =OrderOpenPrice(); // Price of the selected order int Ticket=OrderTicket(); // Ticket of the selected order Alert ("Modification ",Text,Ticket,". Awaiting response.."); bool Ans=OrderModify(Ticket,Price,SLt,TPt,0);//Modify it! //------------------------------------------------------------------- 6 -- if (Ans==true) // Got it! :) { Alert ("Order ",Text,Ticket," is modified:)"); break; // From modification cycle. } //------------------------------------------------------------------- 7 -- break; } // End of modification cycle //---------------------------------------------------------------------- 8 -- } // End of order analysis } // End of order search //------------------------------------------------------------------------------- 9 -- int Error=GetLastError(); // Failed :( switch(Error) // Overcomable errors { case 130:Alert("Wrong stops. Retrying."); RefreshRates(); // Update data // At the next iteration case 136:Alert("No prices. Waiting for a new tick.."); while(RefreshRates()==false) // To the new tick Sleep(1); // Cycle delay // At the next iteration case 146:Alert("Trading subsystem is busy. Retrying "); Sleep(500); // Simple solution RefreshRates(); // Update data // At the next iteration // Critical errors case 2 : Alert("Common error."); // Exit 'switch' case 5 : Alert("Old version of the client terminal."); // Exit 'switch' case 64: Alert("Account is blocked."); // Exit 'switch' case 133:Alert("Trading is prohibited"); // Exit 'switch' default: Alert("Occurred error ",Error);//Other errors } // From modification cycle //------------------------------------------------------------------------------------------------------------------------ // end trail //-------------------------------------------------------------------------------------------------------------------------- } But if you read this code your EA your not selecting Magicnumber with trailing. In this case trades of same currencie found in your orderselect with another magicnumber will be modified by the rules of this EA.... Trie it out if you don't believe me.... Actually this ea works better without trailing i just added it there as an option because of a user requested it and this is why i prefer handling personal customisations separately. 15.11.2011 10:43 tonny
FXSysssr:
Hello Tonny, Unable to get Psar Bug 7 to work without Manual Confirmation. My Sar settings match in EA and indicator (Step .03, Max .2) On platform, Tools ---> Options ---> Unchecked 'Manual Confirmation' What am I doing wrong? Thank you. When you attach the ea and the settings dialogue appears there is a tab called "common" this tab also has settings for live trading and manual confirmation please check if "allow live trading" is checked and "ask manual confirmation" should be unchecked. 15.11.2011 10:38 tonny
...cont'd P.S. I am on a 5-Digit Broker 14.11.2011 23:32 FXSysssr
Hello Tonny,
Unable to get Psar Bug 7 to work without Manual Confirmation. My Sar settings match in EA and indicator (Step .03, Max .2) On platform, Tools ---> Options ---> Unchecked 'Manual Confirmation' What am I doing wrong? Thank you. 14.11.2011 23:22 FXSysssr
tonny:
devries you also might wana read the full psar bug documentation http://www.mql4.com/go?http://www.fxautomated.com/docs/psarbugdoc.php to understand this EA better. The magic number is editable by the user making it more flexible thus its enough to only select magic number only and not ordersymbol too since on different charts, timeframes etc the user can set a different magic number afterall thats the work of magic number otherwise i would'nt have made it editable on the user side. if((Trailing==true)&&(OrdersTotal()>0)){ //----------------------------------------------------------------------------------------------------------------------- // Trail /*-----------------------------------------------------------------------------------------------------------------------*/ string Symb=Symbol(); // Symbol //------------------------------------------------------------------------------- 2 -- for(i=1; i<=OrdersTotal(); i++) // Cycle searching in orders { if (OrderSelect(i-1,SELECT_BY_POS)==true) // If the next is available { // Analysis of orders: int Tip=OrderType(); // Order type if(OrderSymbol()!=Symb||Tip>1)continue;// The order is not "ours" double SLt=OrderStopLoss(); // SL of the selected order //---------------------------------------------------------------------- 3 -- while(true) // Modification cycle { double TS=Tral_Stop; // Initial value int Min_Dist=MarketInfo(Symb,MODE_STOPLEVEL);//Min. distance if (TS < Min_Dist) // If less than allowed TS=Min_Dist; // New value of TS //------------------------------------------------------------------- 4 -- bool Modify=false; // Not to be modified switch(Tip) // By order type { case 0 : // Order Buy if (NormalizeDouble(SLt,Digits)< // If it is lower than we want NormalizeDouble(Bid-TS*Point,Digits)) { SLt=Bid-TS*Point; // then modify it string Text="Buy "; // Text for Buy Modify=true; // To be modified } break; // Exit 'switch' case 1 : // Order Sell if (NormalizeDouble(SLt,Digits)> // If it is higher than we want NormalizeDouble(Ask+TS*Point,Digits) || NormalizeDouble(SLt,Digits)==0)//or equal to zero { SLt=Ask+TS*Point; // then modify it Text="Sell "; // Text for Sell Modify=true; // To be modified } } // End of 'switch' if (Modify==false) // If it is not modified break; // Exit 'while' //------------------------------------------------------------------- 5 -- double TPt =OrderTakeProfit(); // TP of the selected order double Price =OrderOpenPrice(); // Price of the selected order int Ticket=OrderTicket(); // Ticket of the selected order Alert ("Modification ",Text,Ticket,". Awaiting response.."); bool Ans=OrderModify(Ticket,Price,SLt,TPt,0);//Modify it! //------------------------------------------------------------------- 6 -- if (Ans==true) // Got it! :) { Alert ("Order ",Text,Ticket," is modified:)"); break; // From modification cycle. } //------------------------------------------------------------------- 7 -- break; } // End of modification cycle //---------------------------------------------------------------------- 8 -- } // End of order analysis } // End of order search //------------------------------------------------------------------------------- 9 -- int Error=GetLastError(); // Failed :( switch(Error) // Overcomable errors { case 130:Alert("Wrong stops. Retrying."); RefreshRates(); // Update data // At the next iteration case 136:Alert("No prices. Waiting for a new tick.."); while(RefreshRates()==false) // To the new tick Sleep(1); // Cycle delay // At the next iteration case 146:Alert("Trading subsystem is busy. Retrying "); Sleep(500); // Simple solution RefreshRates(); // Update data // At the next iteration // Critical errors case 2 : Alert("Common error."); // Exit 'switch' case 5 : Alert("Old version of the client terminal."); // Exit 'switch' case 64: Alert("Account is blocked."); // Exit 'switch' case 133:Alert("Trading is prohibited"); // Exit 'switch' default: Alert("Occurred error ",Error);//Other errors } // From modification cycle //------------------------------------------------------------------------------------------------------------------------ // end trail //-------------------------------------------------------------------------------------------------------------------------- } But if you read this code your EA your not selecting Magicnumber with trailing. In this case trades of same currencie found in your orderselect with another magicnumber will be modified by the rules of this EA.... Trie it out if you don't believe me.... 14.11.2011 16:10 deVries
devries you also might wana read the full psar bug documentation http://www.fxautomated.com/docs/psarbugdoc.php to understand this EA better. The magic number is editable by the user making it more flexible thus its enough to only select magic number only and not ordersymbol too since on different charts, timeframes etc the user can set a different magic number afterall thats the work of magic number otherwise i would'nt have made it editable on the user side.
14.11.2011 15:16 tonny
deVries:
int digits=MarketInfo("EURUSD",MODE_DIGITS); if(digits==5){StopMultd=10;} else{StopMultd=1;} There are a lot of accounts with added to the currency a prefix or suffix. In that case...... int openbuy=OrderSend(Symbol(),OP_BUY,Lots,Ask,Slip,NormalizeDouble(Ask-SL*Point,Digits),NormalizeDouble(Ask+TP*Point,Digits),"psar bug 6 order ",MagicNumber);//Opening Buy int opensell=OrderSend(Symbol(),OP_SELL,Lots,Bid,Slip,NormalizeDouble(Bid+SL*Point,Digits),NormalizeDouble(Bid-TP*Point,Digits),"psar bug 6 order ",MagicNumber);//Opening Sell Still no coding for working on ECN accounts //-------------------------------------------------------------------+ //Check open orders //-------------------------------------------------------------------+ if(OrdersTotal()>0){ for(int i=1; i<=OrdersTotal(); i++) // Cycle searching in orders { if (OrderSelect(i-1,SELECT_BY_POS)==true) // If the next is available { if(OrderMagicNumber()==MagicNumber) {int halt1=1;} } } } Why not selecting on OrderSymbol and OrderMagicnumber... With trailing you're not selecting the OrderMagicNumber.... ONLY GOOD FOR BACKTESTING ...... Attention all users! This expert advisor of mine of which i have worked hard to provide 100% free is provided as is and free things cant always satisfy personal requirements of everyone. Happy now 🙂 anyway to get serious im stopping further development on psar bug to concentrate on xbug and our premium scripts. For any other custom modifications please contact me i send you a quote but this is pretty much the last or second last psar bug. 14.11.2011 14:58 tonny
int digits=MarketInfo("EURUSD",MODE_DIGITS); if(digits==5){StopMultd=10;} else{StopMultd=1;} There are a lot of accounts with added to the currency a prefix or suffix. In that case...... int openbuy=OrderSend(Symbol(),OP_BUY,Lots,Ask,Slip,NormalizeDouble(Ask-SL*Point,Digits),NormalizeDouble(Ask+TP*Point,Digits),"psar bug 6 order ",MagicNumber);//Opening Buy int opensell=OrderSend(Symbol(),OP_SELL,Lots,Bid,Slip,NormalizeDouble(Bid+SL*Point,Digits),NormalizeDouble(Bid-TP*Point,Digits),"psar bug 6 order ",MagicNumber);//Opening Sell Still no coding for working on ECN accounts //-------------------------------------------------------------------+ //Check open orders //-------------------------------------------------------------------+ if(OrdersTotal()>0){ for(int i=1; i<=OrdersTotal(); i++) // Cycle searching in orders { if (OrderSelect(i-1,SELECT_BY_POS)==true) // If the next is available { if(OrderMagicNumber()==MagicNumber) {int halt1=1;} } } } Why not selecting on OrderSymbol and OrderMagicnumber... With trailing you're not selecting the OrderMagicNumber.... ONLY GOOD FOR BACKTESTING ...... |