Dukascopy
 
 
Wiki JStore Search Login

Attention! Read the forum rules carefully before posting a topic.

    Try to find an answer in Wiki before asking a question.
    Submit programming questions in this forum only.
    Off topics are strictly forbidden.

Any topics which do not satisfy these rules will be deleted.

Strategy selecting displayed Chart
 Post subject: Strategy selecting displayed Chart Post rating: 0   New post Posted: Wed 05 Feb, 2014, 01:49 
User avatar

User rating: 98
Joined: Mon 23 Jul, 2012, 02:02
Posts: 656
Location: United States, Durham, NC
Instead of writing a standalone API client, I wanted
to hack together a simple Strategy in the JForex
context running Locally which would be able to:

1) create multiple charts
2) delete them
(the first 2 things I think the API supports)
3) select which chart I want displayed, and
ensure it is visible

My understanding is that to change the Instrument
for a chart, I wouldn't be able to do that either, and
would have to close the chart and recreate another on
a new IFeedDescriptor in order to display a new
symbol, is that correct ?

But, I won't be able to directly
select a given chart and cause it to be displayed
from an ordinary Strategy, right ?

So I'd have to write a standalone API client to
achieve all of those goals, is that correct ?

HyperScalper


 
 Post subject: Re: Strategy selecting displayed Chart Post rating: 0   New post Posted: Wed 05 Feb, 2014, 16:37 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
hyperscalper wrote:
My understanding is that to change the Instrument
for a chart, I wouldn't be able to do that either, and
would have to close the chart and recreate another on
a new IFeedDescriptor in order to display a new
symbol, is that correct ?
Yes.
hyperscalper wrote:
But, I won't be able to directly
select a given chart and cause it to be displayed
from an ordinary Strategy, right ?
Yes.
hyperscalper wrote:
So I'd have to write a standalone API client to
achieve all of those goals, is that correct ?
Yes. Basically the strategies are not supposed to "take-over" the platform by switching charts, etc. Already opening a chart in a sense provides too much "power" to the strategy.


 
 Post subject: Re: Strategy selecting displayed Chart Post rating: 0   New post Posted: Thu 06 Feb, 2014, 04:17 
User avatar

User rating: 98
Joined: Mon 23 Jul, 2012, 02:02
Posts: 656
Location: United States, Durham, NC
I see where you're headed with these design decisions.

It's just there's such a "huge gulf" between the convenience of
writing an ordinary JForex hosted strategy and coding up
a standalone client. So much is provided by the JForex
platform which needs to be coded separately by a standalone
client, especially in the areas of connection management
and chart attributes control......

I wish that there were a bit more "power" to the strategy,
given that perhaps the platform could "prompt" the user
whether to grant the Strategy privileges such as switching
charts, etc.

Wouldn't that be something to consider? If the platform user
did not want to grant such privileges, then that could be
a method of retain "platform control".

I realize that, in a sense, the Strategy needs to be "sandboxed"
and that certain deprecated functions will eventually be
unavailable. Consider some type of "access control" which
would "control" Strategy privileges but which could also grant
"full control" for Strategies which request that control,
within the JForex host.

HyperScalper


 
 Post subject: Re: Strategy selecting displayed Chart Post rating: 0   New post Posted: Tue 18 Feb, 2014, 06:46 
User avatar

User rating: 98
Joined: Mon 23 Jul, 2012, 02:02
Posts: 656
Location: United States, Durham, NC
OK, just one more question. Still "on topic" ...

Can I do this by somehow inserting a Plugin in the JForex
platform environment? How could I do that?

I think I am doomed to writing my own API client, just
for this purpose, but just one more try at doing it
within the JForex platform environment.

Any suggestions / ideas are welcome...

I've got server doing trades in lots of currency symbols,
so I want to "auto track" these trades by switching
the charting so that they can be easily viewed without
manually having to switch them to the correct charts.

Thanks,
HyperScalper

So I have a thread which periodically calls this routine in
order to "fix" the Stop Loss side, using IContext.executeTask(...)
of course.

   /*
    * When an order is initially placed with a StopLoss, it is not
    * possible to set the Stop "side".  This task replaces the StopPrice
    * but applies the proper Stop "side"
    */
   final public class ResetStopPriceSideTask implements Callable<Void> {
      IEngine _engine = null;
      Instrument _instrument = null;
      public ResetStopPriceSideTask(IEngine engineArg, Instrument instrumentArg) {
         _engine = engineArg;
         _instrument = instrumentArg;
      }
      public Void call() throws Exception {
         try {
            List<IOrder> orders = _engine.getOrders();
            if (orders!=null) {
               for (IOrder order: orders) {
                  if ( !isMyOrder(order)) continue; // skip
                  // now this is my order
                  IOrder.State state = order.getState();
                  if ( !state.equals(IOrder.State.FILLED)) continue; // not filled
                  double stopLossPrice = order.getStopLossPrice();
                  if (stopLossPrice==0) continue; // no stop loss set
                  OfferSide actualStopLossSide = order.getStopLossSide();
                  OfferSide desiredStopLossSide = getStopLossSide(order.isLong());
                  if ( !actualStopLossSide.equals(desiredStopLossSide)) {
                     // replace it at same price with proper "side"
                     try {
                        // fix it
                        order.setStopLossPrice(stopLossPrice, desiredStopLossSide);
                        log("Fixed stopLoss OfferSide for order label: "+order.getLabel());
                     }
                     catch(Exception ee) {
                        log("order.setStopLossPrice error "+ee.getMessage());
                        // nothing
                     }
                  }
               }
            }
         }
         catch(Exception e) {
            e.printStackTrace();
            throw e;
         }
         return null;
      }
   }
   


 
 Post subject: Re: Strategy selecting displayed Chart Post rating: 0   New post Posted: Tue 18 Feb, 2014, 09:36 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
hyperscalper wrote:
Can I do this by somehow inserting a Plugin in the JForex
platform environment? How could I do that?
Plugins have as much functionality as you see in the IPluginContext, thus, no.


 

Jump to:  

  © 1998-2025 Dukascopy® Bank SA
On-line Currency forex trading with Swiss Forex Broker - ECN Forex Brokerage,
Managed Forex Accounts, introducing forex brokers, Currency Forex Data Feed and News
Currency Forex Trading Platform provided on-line by Dukascopy.com