Java API help

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • zingcal
    New Member
    • Sep 2007
    • 2

    #1

    Java API help

    I know very little about programming. I am a registeredf user of a Java program that runs over the net (as far as I can tell it doesn't get loaded on to my computer?) The provider allows for customization through API and they have even provided the approximate code for the custom function I want to employ, but I haven't any idea of how / what to do next?

    Help? Suggestions? Directions?

    Many Thanks
  • Nepomuk
    Recognized Expert Specialist
    • Aug 2007
    • 3111

    #2
    Originally posted by zingcal
    I know very little about programming. I am a registeredf user of a Java program that runs over the net (as far as I can tell it doesn't get loaded on to my computer?) The provider allows for customization through API and they have even provided the approximate code for the custom function I want to employ, but I haven't any idea of how / what to do next?

    Help? Suggestions? Directions?

    Many Thanks
    What is it you want to do? Change something in the code? Use the code? Rewrite it?

    If you want to use it, check the website of that mysterious Java program - I'm sure they'll have some kind of instructions. If you want to edit the code in any way, you'll have to give us more information (i.e. what do you want it to do, what have you got so far, where are you stuck).

    Greetings,
    Nepomuk

    Comment

    • zingcal
      New Member
      • Sep 2007
      • 2

      #3
      Nepomuk thanks for your reply. Here's what they've provided based on what somebody else had requested. I would want to use a modified version of this that would enable me to change the two variables:

      STOP_LOSS_PIPS= xx
      STOP_TRAIL_PIPS =x.x

      ----------------------------------------------------------------------

      Custom functions

      trailingStop

      1. Client placed Market order to sell EUR/USD at 1.2050.
      2. Client attached a Trailing Stop on this order to buy EUR/USD at 1.2070 (20 pips Stop Loss parameter from original trade rate and 5 trailing pips).
      3. Once the market price moved in the client's favor by 5 pips (1.2050 to 1.2045), then the attached stop will be adjusted in a first step by 20 pips (1.2070 to 1.2050).
      4. If prices move back to 1.2050 the stop order will be executed.
      5. If prices move further in favored direction, then the attached stop will be adjusted on every tick when market moves in profit.
      6. Stop level will not move, if Market changed direction and went back on loss direction.

      Listing:

      int STOP_LOSS_PIPS= 20;
      double STOP_TRAIL_PIPS =5.0;

      void trailingStop(Or der order,double levelPips){
      if(order.getPro fitLossPips()>l evelPips){
      // detect current price, for LONG position - stops based on Bid, for SHORT, stops based on Ask
      double basePrix = order.getOrderT ype()==OP_BUY?B id:Ask;
      // position sign. in case of SHORT position we do SL chenging in opposite way
      double directionSign = order.getOrderT ype()==OP_BUY?1 :-1;

      // take current stop loss price
      double currentSLPrice = order.getStopLo ssPrice();
      // detect difference between current price and stop loss level
      double diff = (basePrix - currentSLPrice) *directionSign;
      // same in pips
      double diffPips = Round(diff/PIP,0);

      //print("("+diffP ips+")");
      if(diffPips>lev elPips){
      //difference shouldn't exceed level
      double newSLPrix = (basePrix-(levelPips*PIP* directionSign)) ;
      newSLPrix = Round(newSLPrix ,4);
      print("Triggeri ng trail stop for ["+order.getLabe l()+"
      "+order.get I ()+"], changing stop loss level from "+currentSLPric e+" to "
      +newSLPrix);
      order.submitSto pPrice(OP_STOPL OSS, newSLPrix);
      }
      }
      }

      Comment

      Working...