View Single Post
 
Old 03-30-2007, 10:14 PM
cockeyedcowboy's Avatar
cockeyedcowboy cockeyedcowboy is offline
Senior Member
 
Join Date: Nov 2005
Posts: 476
cockeyedcowboy is on a distinguished road
I came across this post on another thread, I would like to draw you attention to the code sample give. Its part of the new Phoenix stop management.

I never looked at any of daraknor code before and did not care to see this as well. But it was there ... Boy ... am speechless ... What a mess ... He doesnot know how to program, hes learning on this project. I have to say hes a fast learner. But this code is overflowing all over ... its done in a style that will garrantee bugs. He doenot understand Procedural protocal at all and is claming to code in modules. Look at the last function ModifySL() the name implies that the stop loss will be changed but the Take Profit is being changed as well behine the sence without your knowledge. That is so wrong. The function is of BOOL type and returns nothing and no returns statements in any Procedural construction. By the way Learn what the differents between a function procedure and routine procedure are.

I have re-writen the code, don't know if there are any errors in it as I did not check his math nor did I test it. This is a learning exersise for Daraknor.

And if you dont like my spelling TAFF.

The CockeyedCowboy
Rides again



Quote:
Originally Posted by daraknor

Velocity4x is a whitelabel company. I called them and asked a bunch of questions. They share a liquidity pool with IBFX, FXLQ and FXSOL although they did not state so explicitly (vague references to a 3 member exchange, "our bank", and other crap identical to crap fed by the parties mentioned.)

MiG has a very erratic signal from what I saw scanning their charts. We did live testing for Phoenix on several brokers, and FXDD almost always was the top performer. The second in line, occasionally first, was NF. I researched FXDD extensively, but not have done so for NF. PhoenixFund (a nonprofit that funds UN Development Program goals with EA trading proceeds) is now (finally) an IB for FXDD after months of work. (We did testing first, and then went with the winner.)

As for trailing stops, I have had long term 'average wins' several times higher than my TP thanks to tight delayed super-increasing trailing stops. (Eat those news events!) The trailing stop code was developed with the idea that we shouldn't leave pips on the table. Phoenix beta is getting a code cleaning/review from a fellow developer, here is the latest trailing stop code:

Code:
extern int staticTS =20; extern bool MoveTPonTS=1; //increase Trailing stop by this value in pips each time TS is adjusted. Allows good trades to rise higher extern int U_DelayTS=0;
//Every Tick, during order processing: if (ExitManagedOn) trailingStop(myticket,staticTS,U_DelayTS);
void trailingStop (int ticket, int tsvalue, int delayts) { //TS Function, easily called by multiple exit strategies. double slvalue; Debug("EXIT:TS ticket:"+ticket+" tsvalue:"+tsvalue+" delayts:"+delayts); if (OrderType() == OP_BUY) { slvalue=Bid-(Point*tsvalue); if (OrderStopLoss() < slvalue && OrderOpenPrice()+Point*delayts<Bid+tsvalue*Point) { //Debug("OrderSL:" +OrderStopLoss()+ " slvalue:"+ slvalue); if (!ModifySL(slvalue,ticket)) LogError(); } } else { if (OrderType() == OP_SELL) { slvalue=Ask+(Point*tsvalue); if (OrderStopLoss() > slvalue && OrderOpenPrice()-Point*delayts>Ask-tsvalue*Point) { //Debug("OrderSL:" +OrderStopLoss()+ " slvalue:"+ slvalue); ModifySL(slvalue,ticket); } } } } bool ModifySL(double sl, int ticket) { //Moving SL function, easily called by other exit strategies. int MoveTP; if (OrderType() == OP_SELL) MoveTP=MoveTPonTS*(-1); else MoveTP=MoveTPonTS; Debug("MODIFY Ticket:"+ticket+" OpenPrice:"+OrderOpenPrice()+" SL:"+sl+" TP:"+(OrderTakeProfit()+MoveTP*Point)); if(OrderModify(ticket,OrderOpenPrice(),sl,OrderTakeProfit()+MoveTP*Point,0,Red)!=(-1)) LogError(); }



Code:
 
 
 
        extern int
            BaseTrailStop    =  20,          DelayTrailStop  =  0;
        extern bool
            AdvanceTrailStop  =   1;
 
 
        bool
            ManagedStops   =  ON,  // Switch to apply a trailing stop to the system orders.
            DeBugMessages  =  ON;  // Switch to display DeBugging messages for code development stage.
 
 
 
    if( ManagedStops )
        TrailingStop( TicketNumber, BaseTrailStop, DelayTrailStop );
 
 
    //«« <<<< Management of Trailing Stops, Routine Procedure >>>> »»»»»»»»»»»»»»»»»»»»»»»»»»»»
    void
        TrailingStop( int Ticket, int StopValue, int Delay ) {
            double NewStop  =  0;
                if( OrderSelect( Ticket, SELECT_BY_TICKET )  == True );
                    if( OrderType() == OP_BUY ) {
                        NewStop  =  Bid - ( Point * StopValue );
                        if( OrderStopLoss() < NewStop && OrderOpenPrice() + Point * Delay < Bid + StopValue * Point )
                            ModifyStopLoss( Ticket, NewStop ) {
                    } else if( OrderType() == OP_SELL ) {
                        NewStop  =  Ask + ( Point * StopValue );
                        if( OrderStopLoss() > NewStop && OrderOpenPrice() - Point * Delay > Ask - StopValue * Point )
                            ModifyStopLoss( Ticket, NewStop ) {
                    } else {
                        if( DeBugMessages )
                            Print( "Error: Unreconized order type in TSFunction, Order Type: " + OrderType() );
                    } // End if, OrderType:
                } else {
                    if( DeBugMessages )
                        Print( "Error: Unreconized order number in TSFunction, Ticket: " + Ticket );
                } // End If, OrderSelect:
        return;
    } // End Routine Procedure, TrailingStop:
 
 
    //«« <<<< Moddifing of Trailing Stops, Routine Procedure >>>> »»»»»»»»»»»»»»»»»»»»»»»»»»»»»
    void
        ModifyStopLoss( int Order, double MoveStop ) {
            if( OrderModify( Ticket, OrderOpenPrice(), MoveStop, OrderTakeProfit(), 0, Red ) == True ) {
                Print( "Order Stop Loss Modified Order Number: " + Order + " Seccessfully completed" ):
            } else {
                if( DeBugMessages )
                    Print( "Error in ModifyStopLoss Function: Modifing Order Number; " + Order + " Failed" );
            } // End If, OrderModify:
        return;
    } // End Routine Procedure, ModifyStopLoss: